package gatoropoly.game;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

public class GatoropolyListenerDispatcher implements GatoropolyListener {

	List<GatoropolyListener> listeners = new CopyOnWriteArrayList<GatoropolyListener>();

	public void serverVersion(String version) {
		for (GatoropolyListener listener : listeners)
			listener.serverVersion(version);
	}

	public void clientInfo(int playerId, String cookie) {
		for (GatoropolyListener listener : listeners)
			listener.clientInfo(playerId, cookie);
	}

	public void chat(int playerId, String author, String message) {
		for (GatoropolyListener listener : listeners)
			listener.chat(playerId, author, message);
	}

	public void infoAdded(String message) {
		for (GatoropolyListener listener : listeners)
			listener.infoAdded(message);
	}

	public void errorAdded(String message) {
		for (GatoropolyListener listener : listeners)
			listener.errorAdded(message);
	}

	public void xml(String message) {
		for (GatoropolyListener listener : listeners)
			listener.xml(message);
	}

	public void addListener(GatoropolyListener listener) {
		listeners.add(listener);
	}

	public void removeListener(GatoropolyListener listener) {
		listeners.remove(listener);
	}
}
